﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using System.IO;
using System.Data;
using System.Xml;
using System.Xml.Serialization;
using System.Collections;
using System.Web.Script.Serialization;
using System.Web.Script.Services;
using System.Net;

namespace BattleshipPortal.Controllers
{
    public class PlayerController : Controller
    {
        //
        // GET: /History/

        public ActionResult Index()
        {
            HttpWebRequest req;
            string strGet = "http://localhost:48361/IBattleship.asmx/getUserList";
            strGet = strGet + "";
            req = (HttpWebRequest)WebRequest.Create(strGet);
            HttpWebResponse response;
            response = (HttpWebResponse)req.GetResponse();
            Stream stream = response.GetResponseStream();
            XmlTextReader reader = new XmlTextReader(stream);
            reader.MoveToContent();

            string content  = reader.ReadInnerXml();

            ViewData["Message"] = content;

            
            reader.Close();

            string[,] myArray2; 

            string[] strColumn; //第一次截取  ";"
            string[] strRow; //第二次截取  ","

            strColumn = content.Split(';');//第一次截取 
            int p_Count = strColumn.Length;

            myArray2 = new string[p_Count, 7];
            //for (int i = 0; i <= p_Count - 1; i++) //将数据保存 数组 myArray1 中
            //{
            //    strRow = strColumn[i].Split(',');//第二次截取
            //    myArray2[i, 0] = strRow[0];
            //    myArray2[i, 1] = strRow[1];
            //}

            ViewData["list"] = strColumn;

            return View();
        }
    }
}
